import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class JrIconButton extends StatelessWidget {
  final Widget icon;
  final VoidCallback onTap;
  const JrIconButton({Key? key, required this.icon, required this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 28.h,
        decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: const Color(0xFF635FDD).withOpacity(0.3)),
        child: Center(
          child: icon,
        ),
      ),
    );
  }
}

class JrStyledButton extends StatelessWidget {
  final String text;
  final VoidCallback onTap;
  final double? height;
  final double? width;
  const JrStyledButton({Key? key, required this.text, required this.onTap, this.height, this.width}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: height ?? 38.h,
        width: width ?? 100.w,
        decoration: BoxDecoration(
            image: const DecorationImage(image: AssetImage('assets/webp/img_styled_button_bg.webp'), fit: BoxFit.fill),
            borderRadius: BorderRadius.circular(10)),
        child: Center(
          child: Text(
            text,
            style: const TextStyle(color: Colors.white),
          ),
        ),
      ),
    );
  }
}

class JrGradientButton extends StatelessWidget {
  final String text;
  final TextStyle? textStyle;
  final VoidCallback onTap;
  final double? height;
  final double? width;
  final LinearGradient? gradient;
  final EdgeInsets? padding;
  // final
  const JrGradientButton(
      {Key? key, required this.text, required this.onTap, this.height, this.width, this.gradient, this.padding, this.textStyle})
      : super(key: key);

  static const defaultGradient = LinearGradient(
    begin: Alignment.bottomLeft, // start at the bottom left
    end: Alignment.topRight, // end at the top right
    colors: [
      Color(0xFF683F68), // left bottom corner color
      Color(0xFF9248B7), // right top corner color
    ],
  );
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: height ?? 48.h,
        width: width ?? double.infinity,
        padding: padding,
        decoration: BoxDecoration(
            gradient: gradient ?? defaultGradient, borderRadius: BorderRadius.circular((height ?? 48.h / 2))),
        child: Center(
          child: Text(
            text,
            style: textStyle ?? const TextStyle(color: Colors.white),
          ),
        ),
      ),
    );
  }
}
